﻿using Microsoft.Extensions.DependencyInjection;
using Production.RazorLib.Services;

namespace Production.RazorLib
{
    public static class ServiceCollectionExtensions
    {
        public static void AddProductionBlazor(this IServiceCollection services)
        {
            services.AddScoped<ExampleJsInterop>();


            services.AddAuthorizationCore(options =>
            {
                // RegisterPermissionClaims(options);
            });

            services.AddTransient<ITechnologyService, TechnologyService>();
            services.AddTransient<IStandardBomService, StandardBomService>();
            services.AddTransient<IMaterialCategoryService, MaterialCategoryService>();
            services.AddTransient<IMaterialService, MaterialService>();
            services.AddTransient<IProcessService, ProcessService>();
            services.AddTransient<IProductionPlanService, ProductionPlanService>();
            services.AddTransient<IProductionOrderService, ProductionOrderService>();
            services.AddTransient<IProductionResourceService, ProductionResourceService>();
        }

        // private static void RegisterPermissionClaims(AuthorizationOptions options)
        // {
        //     foreach (var prop in typeof(ApiRoutes).GetNestedTypes().SelectMany(c =>
        //                          c.GetFields(BindingFlags.Public | BindingFlags.Static |
        //                                      BindingFlags.FlattenHierarchy)))
        //     {
        //         options.AddPolicy(prop.Name,
        //             policy => policy.RequireClaim(ApplicationClaimTypes.Permission,
        //                 prop.Name));
        //     }
        // }
    }
}